<?php
include_once 'config.php';
include_once 'common_functions.php';

$names = array('Jonathan Dawnchaser', 'Evanga', 'Alpais', 'Helen Highwater', 'Meissa Anunthiel', 'Alekseyev Karrde', 'mduncan0341', 'FnDragon', 'Daugar Draaken'
				,'Basta Ya', 'PsychoBitch', 'Zastrow', 'Mrs Trzzbk', 'Farscape Hw', "T'Amber", 'Song Li', 'Mike Azariah', 'ElvenLord', 'Qual', 'Prodigal' 
				,'Damar Rocarion', 'Aspherical', 'Feyloan', 'Admiral IceBlock', 'Ahsekuaw', 'Gimmickname Goonface', 'Liiza Valora', 'Logit Probit', 'Tetsujin'
				,"Khiritor O'Ammarr", 'Sokratesz', 'Kirana', 'Kornel', 'Korvin', 'Lore Byron', 'Stormaxe Titanothere', 'Z0D', 'TeaDaze', 'enterion inforcer'
				,'greymouse', 'Serenity Steele', 'Vire Amarr', 'Herschel Yamamoto', 'Aaron Mirrorsaver', 'Furry Crusader', 'Extreme', 'Aynen', 'Darth Sith', 'Ashina Sito');
//48 - 57
//65 - 90
//97 - 122
$mail = "";
for($i = 0; $i < count($names); $i++) {
	$string = getPassword();
	$line1 =  '<b>Name</b> ' . $names[$i] . '<br />';
	$line2 = '<b>Password</b> ' . $string . '<br />';
	$hash = sha1($string);
	$line3 = '<b>Hash</b> ' . $hash . '<br /><br />';
	
	echo $line1;
	echo $line2;
	echo $line3;
	
	$mail = $mail . $line1 . $line2 . $line3;
	$name = sanitize($names[$i]);	
	$query = "INSERT INTO Candidates (election_id, candidate_name, candidate_password) VALUES ('3', '$name', '$hash');";
	
    queryDB($query);

}

//mail('vgeirnaert@xs4all.nl', 'passwords', $mail);

function getChar() {
	$int = rand(48, 109);

	if($int > 57)
		$int = $int + 7;
	
	if($int > 90)
		$int = $int + 6;
	
	return chr($int);
}

function getPassword() {
	$string = "";
	for($i = 0; $i < 8; $i++) {
		$string = $string . getChar();
	}
	
	return $string;
}
?>